<template>
  <div class="noticeBar" @click="showDrawer" :style="view?'border: none !important;':'cursor: pointer;'">
    <van-notice-bar :scrollable="props.scrollable" :text="props.text" >
      <template slot="left-icon"> 
        <a-icon v-if="props.icon" :type="props.icon" style="margin-right:12px;font-size:16px;" />
      </template>
    </van-notice-bar>
    <drawer :attr="list.attr" :show.sync="show" @change="editAttr" :index="list.index" />
  </div>
</template>

<script>
import drawer from "../drawer"
import changeAttr from '@/utils/changeAttr.js'
import changeViewAttr from '@/utils/changeViewAttr.js'

export default {
  components:{
    drawer,
  },
  name:"noticeBar",
  props:{
    list:{
      type:Object,
    },
    view:{
      type:Boolean,
      default:false
    }
  },
  data() {
    return {
      show:false,
      props:{},
      changeAttr,
    }
  },
  created() {
    this.editAttr()
  },
  methods: {
    showDrawer(){
      if(!this.view){
        this.show = true
      }
    },
    editAttr(){
      if(this.view){
        this.props = changeViewAttr(this.list.attr,this.list.index)
      }else{
        this.props = changeAttr(this.list.attr,this.list.index)
      }
    }
  },
}
</script>

<style scoped>
  .noticeBar{
    box-sizing: border-box;
    border: 1px dashed transparent;
  }
  .noticeBar:hover{
    border: 1px dashed #1989fa;
  }
</style>